package work.jame.blog.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import work.jame.blog.framework.limit.RequestLimit;
import work.jame.blog.framework.result.Result;
import work.jame.blog.pojo.dto.SearchDTO;
import work.jame.blog.pojo.vo.HomeDataVO;
import work.jame.blog.pojo.vo.SearchVO;
import work.jame.blog.service.impl.HomeService;

/**
 * @author : Jame
 * @date : 2023-06-08 14:46
 **/
@Api(tags = "首页")
@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private HomeService homeService;


    @RequestLimit
    @ApiOperation("查询首页数据")
    @GetMapping("/queryHomeData")
    public Result<?> queryHomeData() {
        HomeDataVO homeData = homeService.queryHomeData();
        return Result.succeed(homeData);
    }

    @RequestLimit
    @ApiOperation("搜索接口")
    @PostMapping("/search")
    public Result<?> search(@Validated @RequestBody SearchDTO searchDTO) {
        SearchVO searchVO = homeService.search(searchDTO);
        return Result.succeed(searchVO);
    }


}
